package com.devcon5.StudentPlanner;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class PlannerTabManager extends TabActivity{

	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		Resources res = getResources(); //Retrieves drawables (icons and such)
		TabHost tabHost = getTabHost(); //Retrieves activity TabHost
		TabHost.TabSpec spec;	//TabSpec for each tab (reusable)
		Intent intent;	//Intent for each tab (reusable)
		
		//Create an Intent to launch the activity associated with the tab (reusable)
		intent = new Intent().setClass(this, ViewAssignments.class);
		
		//Build a Tab Specification for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("Assignments").setIndicator("Assignments",
				res.getDrawable(R.drawable.assignments)).setContent(intent);	
				//Will replace ic_launcher icon with assignment icon
		tabHost.addTab(spec);
		
		//Repeat for Courses Tab
		intent = new Intent().setClass(this, ViewCourses.class);
		
		//Build a Tab Specification for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("Courses").setIndicator("Courses",
				res.getDrawable(R.drawable.courses)).setContent(intent);	
				//Will replace ic_launcher icon with courses icon
		tabHost.addTab(spec);
		
		//Repeat for Courses Tab
		intent = new Intent().setClass(this, ViewGrades.class);
				
		//Build a Tab Specification for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("Grades").setIndicator("Grades",
				res.getDrawable(R.drawable.grades)).setContent(intent);	
				//Will replace ic_launcher icon with grades icon
		tabHost.addTab(spec);
		
		//Repeat for Messages Tab
				intent = new Intent().setClass(this, ViewMessages.class);
						
				//Build a Tab Specification for each tab and add it to the TabHost
				spec = tabHost.newTabSpec("Messages").setIndicator("Messages",
						res.getDrawable(R.drawable.messages)).setContent(intent);	
						//Will replace ic_launcher icon with grades icon
				tabHost.addTab(spec);
		
		tabHost.setCurrentTab(0); //Sets first tab (Assignments) to have focus on load
	}
}
